package com.leyou.test1.mongodb;

import com.leyou.dto.FriendsDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/api/mon")
public class MongoDemo {

    @Autowired
    private MongoTemplate mongoTemplate;

    @PostMapping("/save")
    public void storeUser(){
        FriendsDto friends = new FriendsDto();
        friends.setAge(20);
        friends.setName("诸葛亮");
        mongoTemplate.save(friends);
    }
}
